import { Component,Injectable} from '@angular/core';
import { MyScoresService} from './myScores.service';
@Component({
    selector: 'my-scores',
    templateUrl: './myScores.component.html',
    styleUrls: ['./myScores.component.less'],
    providers:[MyScoresService]
})
@Injectable()
export class MyScoresComponent {
  tableData:any[];
  page:{
    pageIndex:number,
    pageSize:number,
    count:number
  };
  searchParams:{
    keyword:string
  };
  constructor(private svc:MyScoresService){
    this.resetParams();
    this.page={
      pageIndex:0,
      pageSize:10,
      count:0
    };
  }
  resetParams(){
    this.searchParams={
      keyword:''
    }
  }
  search(){
    this.page.pageIndex=0;
    this.page.count=1;
    this.tableData=[];
    this.query();
  }
  query(){
    let params={
      keyword:this.searchParams.keyword
    };
    this.svc.query(params)
      .then((res)=>{
        console.log(res);
        this.tableData=res.items;
        this.page.count=res.count;
      });
  }
}
